# 操作给定的二叉树，将其变换为源二叉树的镜像。
# 输入描述:
'''
二叉树的镜像定义：源二叉树
    	    8
    	   /  \
    	  6   10
    	 / \  / \
    	5  7 9 11
    	镜像二叉树
    	    8
    	   /  \
    	  10   6
    	 / \  / \
    	11 9 7  5
'''


# 只要用一个temp节点，每个节点左右互换就好了
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None


def Mirror(root):
    if not root:
        return
    # if root.left==None:
    #     root.left = root.right
    # elif root.right==None:
    #     root.right = root.left
    # else:
    root.left, root.right = root.right, root.left
    Mirror(root.left)
    Mirror(root.right)
    return root


treeNode1 = TreeNode(1)
treeNode2 = TreeNode(2)
treeNode3 = TreeNode(3)
treeNode4 = TreeNode(4)
treeNode5 = TreeNode(5)

treeNode1.left = treeNode2
treeNode1.right = treeNode3
# treeNode2.left = treeNode4
# treeNode2.right = treeNode5

'''
    	    1
    	   /  \
    	  2   3
    	 / \  
    	4  5 
'''
root = Mirror(treeNode1)
print(root)